package yohoho.vpn;

public final class Assert
{

    private Assert()
    {
    }

    public static void isTrue(boolean flag)
    {
        isTrue(flag, "[Assertion failed] expression is expected to be true");
    }

    public static void isTrue(boolean flag, String s)
    {
        if(!flag)
            throw new AssertionError(s);
        else
            return;
    }

    public static void isFalse(boolean flag)
    {
        isFalse(flag, "[Assertion failed] expression is expected to be true");
    }

    public static void isFalse(boolean flag, String s)
    {
        if(flag)
            throw new AssertionError(s);
        else
            return;
    }

    public static void notNull(Object obj)
    {
        notNull(obj, "[Assertion failed] expression is expected NOT null");
    }

    public static void notNull(Object obj, String s)
    {
        if(obj == null)
            throw new AssertionError(s);
        else
            return;
    }

    public static void isNull(Object obj)
    {
        isNull(obj, "[Assertion failed] expression is expected to be null");
    }

    public static void isNull(Object obj, String s)
    {
        if(obj != null)
            throw new AssertionError(s);
        else
            return;
    }

    public static void isEquals(Object obj, Object obj1)
    {
        isEquals(obj, obj1, "[Assertion failed] objects are expected to be equals");
    }

    public static void isEquals(Object obj, Object obj1, String s)
    {
        if(obj == null || !obj.equals(obj1))
            throw new AssertionError(s);
        else
            return;
    }
}
